package sistema.controleVendas.fachadas;

import java.io.IOException;
import java.util.Scanner;

import sistema.controleVendas.persistencia.GerenciarBackupPersistencia;

public class GerenciarBackupFachada {
	private static GerenciarBackupFachada singleton;
	private GerenciarBackupPersistencia gbp = new GerenciarBackupPersistencia();
	private GerenciarBackupFachada(){}
	public static GerenciarBackupFachada getInstance(){
		if(singleton==null){
			singleton = new GerenciarBackupFachada();
		}
		return singleton;
	}
	public void fazerBackup(){

		 try {
			Scanner s = new Scanner(Runtime.getRuntime()
					.exec("C:\\Program Files\\PostgreSQL\\8.2\\bin\\pg_dump.exe -i -h localhost -p 5432 -U postgres -F t -b -v -f C:\\controle.backup controledevendas")

					//-i -h 127.0.0.1 -p 5432 -U postgres -F c -b -v -f C:\\banco.backup controleDeVendas"
					//-i -h localhost -p 5432 -U postgres -F p -a -v -f "controledevendas" controledevendas
					.getInputStream());
			//C:\Program Files\PostgreSQL\8.2\bin\pg_dump.exe -i -h localhost -p 5432 -U postgres -F p -v -f "C:\controle" controledevendas
			//C:\\Program Files\\PostgreSQL\\8.2\\bin\\
			//C:\\Arquivos de programas\\PostgreSQL\\8.1\\bin\\
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void fazerRestore(){
		 try {
				Scanner s = new Scanner(Runtime.getRuntime()
						.exec("C:\\Program Files\\PostgreSQL\\8.2\\bin\\pg_restore.exe -i -h localhost -p 5432 -U postgres -d controledevendas -v C:\\controle.backup")
						.getInputStream());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

	}

}
